import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "home",
    component: () => import("../views/home/index.vue"),
    meta: {
      show: true,
      edit: false,
    },
  },
  {
    path: "/books",
    name: "books",
    component: () => import("../views/books/index.vue"),
    meta: {
      show: true,
      edit: false,
    },
  },
  {
    path: "/course",
    name: "course",
    component: () => import("../views/course/index.vue"),
    meta: {
      show: true,
      edit: false,
    },
  },
  {
    path: "/message",
    name: "message",
    component: () => import("../views/message/index.vue"),
    meta: {
      show: true,
      edit: false,
    },
  },
  {
    path: "/mine",
    name: "mine",
    component: () => import("../views/mine/index.vue"),
    meta: {
      show: true,
      edit: false,
    },
    // beforeEnter: (to, from, next) => {
    //   if (localStorage.getItem("token")) {
    //     next();
    //   } else {
    //     next("/login");
    //   }
    // },
  },
  {
    path: "/myfollow",
    name: "myfollow",
    component: () => import("../views/mine/myfollow.vue"),
    meta: {
      edit: true,
      show: false,
      title: "我的关注",
    },
  },
  {
    path: "/Collection",
    name: "Collection",
    component: () => import("../views/mine/Collection.vue"),
    meta: {
      edit: true,
      show: false,
      title: "我的收藏",
    },
  },
  {
    path: "/curriculum",
    name: "curriculum",
    component: () => import("../views/mine/curriculum.vue"),
    meta: {
      edit: true,
      show: false,
      title: "课程订单",
    },
  },
  {
    path: "/memberorder",
    name: "memberorder",
    component: () => import("../views/mine/memberorder.vue"),
    meta: {
      edit: true,
      show: false,
      title: "会员订单",
    },
  },
  {
    path: "/Appointment",
    name: "Appointment",
    component: () => import("../views/mine/Appointment.vue"),
    meta: {
      edit: true,
      show: false,
      title: "约课订单",
    },
  },
  {
    path: "/member",
    name: "member",
    component: () => import("../views/mine/member.vue"),
    meta: {
      edit: true,
      show: false,
      title: "开通会员",
    },
  },
  {
    path: "/coupon",
    name: "coupon",
    component: () => import("../views/mine/coupon.vue"),
    meta: {
      edit: true,
      show: false,
      title: "优惠券",
    },
  },
  {
    path: "/Studycard",
    name: "Studycard",
    component: () => import("../views/mine/Studycard.vue"),
    meta: {
      edit: true,
      show: false,
      title: "学习卡",
    },
  },
  {
    path: "/personal",
    name: "personal",
    component: () => import("../views/mine/personal.vue"),
    meta: {
      edit: true,
      show: false,
      title: "个人信息",
    },
  },
  {
    path: "/nickname",
    name: "nickname",
    component: () => import("../views/mine/nickname.vue"),
    meta: {
      edit: true,
      show: false,
      title: "修改个人信息",
    },
  },
  {
    path: "/sex",
    name: "sex",
    component: () => import("../views/mine/sex.vue"),
    meta: {
      edit: true,
      show: false,
      title: "修改个人信息",
    },
  },
  {
    path: "/subject",
    name: "subject",
    component: () => import("../views/mine/subject.vue"),
    meta: {
      edit: true,
      show: false,
      title: "修改个人信息",
    },
  },
  {
    path: "/courseDetail",
    name: "courseDetail",
    component: () => import("../views/home/courseDetail.vue"),
    meta: {
      show: false,
      edit: true,
    },
  },
  {
    path: "/newsDetail",
    name: "newsDetail",
    component: () => import("../views/home/newsDetail.vue"),
    meta: {
      show: false,
      edit: true,
    },
  },
  {
    path: "/login",
    name: "login",
    component: () => import("../views/login/login.vue"),
    meta: {
      show: false,
      edit: true,
    },
  },
  {
    path: "/reg",
    name: "reg",
    component: () => import("../views/login/reg.vue"),
    meta: {
      show: false,
      edit: true,
    },
  },
  {
    path: "/edit",
    name: "edit",
    component: () => import("../views/login/edit.vue"),
    meta: {
      show: false,
      edit: true,
    },
  },
];

const router = new VueRouter({
  routes,
});

export default router;
